package com.bush.mall.order.controller;

import org.springframework.web.bind.annotation.*;
import com.bush.mall.common.entity.Result;;
import com.bush.mall.order.entity.OrderEntity;
import com.bush.mall.order.service.OrderService;
import javax.annotation.Resource;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;

/**
 * 订单
 * @author RUN
 * @date 2022-11-29
 */
@RestController
@RequestMapping("order")
@Api(tags = "订单管理" )
public class OrderController {

    @Resource(name= OrderService.BEAN_ID)
    private OrderService orderService;

    /**
     * 分页查询订单列表
     * @author RUN
     * @date 2022-11-29
     */
    @ApiOperation(value = "分页查询订单列表")
    @GetMapping("queryForPage")
    public Result queryForPage(Integer current,Integer size){
        return orderService.queryForPage(current,size);
    }

    /**
     * 保存订单表单
     * @author RUN
     * @date 2022-11-29
     */
    @ApiOperation(value = "保存订单表单")
    @PostMapping
    public Result saveOrder(@RequestBody OrderEntity order){
        return orderService.saveOrder(order);
    }

    /**
     * 修改订单表单
     * @author RUN
     * @date 2022-11-29
     */
    @ApiOperation(value = "修改订单表单")
    @PutMapping
    public Result updateOrder(@RequestBody OrderEntity order){
        return orderService.updateOrder(order);
    }

    /**
     * 通过指定id删除订单
     * @author RUN
     * @date 2022-11-29
     */
    @ApiOperation(value = "通过指定id删除订单")
    @DeleteMapping
    public Result deleteOrder(Long id){
        return orderService.deleteOrder(id);
    }

}
